package com.cc.moxingvoice.ui.start;

import com.cc.moxingvoice.R;
import com.cc.moxingvoice.base.BaseActivity;
import com.cc.moxingvoice.ui.main.MainActivity;
import com.mob.analysdk.AnalySDK;
import com.mob.analysdk.User;
import com.superc.cframework.utils.SPUtil;

/**
 * 创建日期：2018/2/23 on 8:39
 * 描述：
 * 作者：郭士超
 * QQ：1169380200
 */

public class StartActivity extends BaseActivity {

    @Override
    protected void initBinding() {

    }

    @Override
    protected void init() {
        setContentView(R.layout.activity_start);

        toMainActivity();

        initUser();

        AnalySDK.trackEvent("startApp");
    }

    private void toMainActivity() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1 * 1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    startActivity(MainActivity.class);
                    finish();
                }
                startActivity(MainActivity.class);
                finish();
            }
        }).start();
    }

    private void initUser() {
        String timeStamp = SPUtil.get(getContext(), "time_id", "");
        if (timeStamp.equals("")) {
            timeStamp = System.currentTimeMillis() + "";
            SPUtil.put(getContext(), "time_id", timeStamp);
        }
        String userId = "Id" + timeStamp;

        User userData = new User();
        userData.name = "Time" + timeStamp;
//        userData.gender = User.Gender.Man;
//        userData.country = "PRC";

        AnalySDK.identifyUser(userId, userData);
    }

}
